//
// Created by xili on 2024/10/8 18:29.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int longestSemiRepetitiveSubstring(string s) {
        int slow = 0, fast = 1;
        int index = -1;
        int n = s.size();
        int ans = 0;
        for (; fast < n; fast++) {
            if (s[fast] == s[fast - 1]) {
                if (index != -1) {
                    ans = max(ans, fast - slow + 1);
                    slow = index;
                }
                index = fast;
            }
        }
        return max(ans, fast - slow + 1);
    }
};